package edu.ycu.aladdin.web.config.oauth;

import edu.ycu.aladdin.web.utils.StringUtils;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 1.0
 */
@ToString
@Configuration
@ConfigurationProperties(prefix = "aladdin.oauth.github")
public class GithubOauthConfig {

    private String client_id;

    private String client_secret;

    private String access_url;

    private String user_info_url;

    private String guid_url;

    public String getAccess_url(String code) {
        return access_url.replace("{{code}}",code);
    }

    public String getClient_id() {
        return client_id;
    }

    public void setClient_id(String client_id) {
        this.client_id = client_id;
    }

    public String getClient_secret() {
        return client_secret;
    }

    public void setClient_secret(String client_secret) {
        this.client_secret = client_secret;
    }

    public void setAccess_url(String access_url) {
        this.access_url = StringUtils.removeAllBlankChar(access_url);
    }

    public String getUser_info_url(String accessToken) {
        return user_info_url.replace("{{access_token}}",accessToken);
    }

    public void setUser_info_url(String user_info_url) {
        this.user_info_url = StringUtils.removeAllBlankChar(user_info_url);
    }

    public String getGuid_url() {
        return guid_url;
    }

    public void setGuid_url(String guid_url) {
        this.guid_url = StringUtils.removeAllBlankChar(guid_url);
    }
}
